import { reactive, ref } from "vue";
import { Api } from "../../api/api.js";
import { ElNotification } from 'element-plus';
function controlJs() {
    let userlist = ref([]);
    let status =reactive({
        findData:{
            limit:10,
            page:1,
            user:undefined,
            pages:"",
            total:""
        },
    })
    let methodFun = {
        //获取所有用户信息
        getUser: () => {
            Api.userFind(status.findData).then((res) => {
                userlist.value = [...res.data.data];
                status.findData.page = res.data.page;
                status.findData.pages = res.data.pages;
                status.findData.total = res.data.total;
            })
        },
        //更改用户权限
        limitChange: (val) => {
            Api.changeControl(val).then((res) => {
                if (res.data) {
                    ElNotification({
                        type: "success",
                        title: "操作成功",
                        message: "用户权限已更新！",
                        duration: 1000,
                    });
                }
            })
        },
        disablefun(item, val) {
            //    判断是不是超管账号
            if (item.user == "loveyou") {
                // 是的话判断是不是权限没开
                console.log(`${item.limitMange[`${val}`]}`);
                return item.limitMange[`${val}`];
            } else {
                return false;
            }
        }
    }
    return {
        status,
        methodFun,
        userlist
    }
}
export default controlJs;